import type { App } from 'vue';

// 自动导入 components 文件夹下的所有组件
const components = import.meta.glob('/src/components/**/index.vue', { eager: true });

export default (app: App) => {
    // 遍历所有组件并自动注册
    Object.keys(components).forEach((key) => {
        const component = components[key] as any;
        if (component.default) {
            // 从路径中提取组件名称
            const componentName = key
                .replace('/@/components/', '')
                .replace('/index.vue', '')
                .split('/')
                .pop();            
            if (componentName) {
                app.component(componentName, component.default);
            }
        }
    });
}